package com.sc.VenusQueryBeta.model.vip;

import com.hengjun.kingstar.sdk.base.BaseModel;
import com.hengjun.kingstar.sdk.helper.RetrofitCreateHelper;
import com.hengjun.kingstar.sdk.helper.RxHelper;
import com.sc.VenusQueryBeta.api.Host;
import com.sc.VenusQueryBeta.api.account.AccountApi;
import com.sc.VenusQueryBeta.api.login.LoginApi;

import com.sc.VenusQueryBeta.contract.vip.VipUserContract;
import com.sc.VenusQueryBeta.model.bean.account.List;
import com.sc.VenusQueryBeta.model.bean.login.QueryRegisBean;

import io.reactivex.Observable;

/**
 * Created by SC-02 on 2018/9/19.
 * vip用户model 继承Basemodel 并且实现契约累的model方法
 */
public class VipUserModel extends BaseModel implements VipUserContract.IVipModel {
    /**
     * 实例化
     * @return 该对象
     */
    public static VipUserModel newInstance(){return  new VipUserModel();}

   /**
     * 查询注册服务器
     * @param id
     * @return
             */
    @Override
    public Observable<QueryRegisBean> queryRegisterServerSetting(String id) {
        return RetrofitCreateHelper.createApi(LoginApi.class, Host.HostVGSestMessageserver).queryRegist(id).compose(RxHelper.<QueryRegisBean>rxSchedulerHelper());
    }


    /**
     * 查询账户列表
     * @param serverAddress
     * @param projectName
     * @param serverPort
     * @param loginBeanId
     * @return
     */
    @Override
    public Observable<List> queryAccountList(String serverAddress, String projectName, int serverPort, String loginBeanId) {
//        LogUtils.e("sasasasas==="+Host.base+serverAddress+":"+serverPort+"/"+projectName+"/");
        return RetrofitCreateHelper.createApi(AccountApi.class, Host.base+serverAddress+":"+serverPort+"/"+projectName+"/").queryRegist(loginBeanId).compose(RxHelper.<List>rxSchedulerHelper());

    }

    /**
     * 查询是否有登录的户口密码
     * @param clientindex
     * @param serverSettingIndex
     * @return
     */
    @Override
    public Observable<String> queryRegistPassword(int clientindex, String serverSettingIndex) {

        return RetrofitCreateHelper.createApi(AccountApi.class, Host.HostVGSestMessageserver).queryRegistPassword(clientindex,serverSettingIndex).compose(RxHelper.<String>rxSchedulerHelper());
    }

    /**
     * 发送验证码
     * @param clientindex
     * @return
     */
    @Override
    public Observable<String> sendcode(int clientindex) {
        return RetrofitCreateHelper.createApi(AccountApi.class, Host.HostVGSestMessageserver).sendcode(clientindex).compose(RxHelper.<String>rxSchedulerHelper());
    }

    @Override
    public Observable<String> sethukoupwd(String clientindex, String verificaCode, String smsQueryPassword, String serverSettingIndex) {
        return null;
    }

    /**
     * 设置户口密码
     * @param clientindex
     * @param verificaCode
     * @param smsQueryPassword
     * @param serverSettingIndex
     * @return
     */
    @Override
    public Observable<String> sethukoupwd(int clientindex, String verificaCode, String smsQueryPassword, String serverSettingIndex) {
        return RetrofitCreateHelper.createApi(AccountApi.class, Host.HostVGSestMessageserver).sethukoupwd(clientindex,verificaCode,smsQueryPassword,serverSettingIndex).compose(RxHelper.<String>rxSchedulerHelper());
    }

    //户口密码输入时查询密码正确
    @Override
    public Observable<String> conFirmPwd(String serverAddress, String projectName, int serverPort, String smsQueryPassword, String clientid) {
        return RetrofitCreateHelper.createApi(AccountApi.class, Host.base+serverAddress+":"+serverPort+"/"+projectName+"/").conFirmPwd(smsQueryPassword,clientid).compose(RxHelper.<String>rxSchedulerHelper());
    }
}
